<template>
  <div class="stat-card" :class="`stat-card--${color}`">
    <div class="stat-card__header">
      <div class="stat-card__icon">{{ icon }}</div>
      <div class="stat-card__trend" :class="trendClass">
        {{ trend }}
      </div>
    </div>
    <div class="stat-card__content">
      <div class="stat-card__value">{{ value }}</div>
      <div class="stat-card__title">{{ title }}</div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed } from 'vue'

interface Props {
  title: string
  value: string | number
  icon: string
  trend?: string
  color?: 'blue' | 'green' | 'purple' | 'orange' | 'red'
}

const props = withDefaults(defineProps<Props>(), {
  trend: '',
  color: 'blue'
})

const trendClass = computed(() => {
  if (!props.trend) return ''
  
  if (props.trend.startsWith('+')) {
    return 'stat-card__trend--positive'
  } else if (props.trend.startsWith('-')) {
    return 'stat-card__trend--negative'
  } else {
    return 'stat-card__trend--neutral'
  }
})
</script>

<style scoped>
.stat-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 1.5rem;
  backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-color);
  opacity: 0.8;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-color);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.stat-card--blue {
  --accent-color: #00d4ff;
}

.stat-card--green {
  --accent-color: #00ff88;
}

.stat-card--purple {
  --accent-color: #8b5cf6;
}

.stat-card--orange {
  --accent-color: #f59e0b;
}

.stat-card--red {
  --accent-color: #ef4444;
}

.stat-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.stat-card__icon {
  font-size: 2rem;
  opacity: 0.8;
}

.stat-card__trend {
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
}

.stat-card__trend--positive {
  color: #00ff88;
  background: rgba(0, 255, 136, 0.1);
}

.stat-card__trend--negative {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.stat-card__trend--neutral {
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.1);
}

.stat-card__content {
  text-align: left;
}

.stat-card__value {
  font-size: 2rem;
  font-weight: bold;
  color: #ffffff;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.stat-card__title {
  font-size: 0.875rem;
  color: #94a3b8;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .stat-card {
    padding: 1rem;
  }
  
  .stat-card__value {
    font-size: 1.5rem;
  }
  
  .stat-card__icon {
    font-size: 1.5rem;
  }
}
</style>